<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>考试安排</title>
    <link href="../../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <link href="../../static/css/dashboard.css" rel="stylesheet" th:href="@{/static/css/dashboard.css}">
</head>
<body>
<div th:insert="admin/common::topbar"></div>
<div class="container-fluid">
    <div class="row">
        <!--侧边栏-->
        <div th:insert="~{admin/common::sidebar(active='examArrange.html')}">
        </div>
        <!--"-->
        <main class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" role="main">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h3>考生成绩</h3>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group mr-2">
                        <form id="form" method="post" th:action="@{/admin/toShowStuExamInfo}">
                            <!--onblur 失去焦点产生事件-->
                            <div class="input-group">
                                <select class="form-control" id="exam_id" name="exam_id">
                                    <option th:each="examlist:${examList}"
                                            th:selected="${exam_id==examlist.getExam_id()}"
                                            th:text="${examlist.getExam_name()}"
                                            th:value="${examlist.getExam_id()}"></option>
                                </select>
                                <select class="form-control" id="classid" name="classid">
                                    <option th:each="classInfo:${classInfoList}"
                                            th:selected="${classById.getClassid()==classInfo.getClassid()}"
                                            th:text="${classInfo.getClass_name()}" th:value="${classInfo.getClassid()}">
                                    </option>
                                </select>
                                <select class="form-control" id="exam_cid" name="exam_cid">
                                    <option th:each="examSuject:${examSubjectList}"
                                            th:selected="${exam_cid==examSuject.getExam_cid()}"
                                            th:text="${examSuject.getExam_cname()}"
                                            th:value="${examSuject.getExam_cid()}"></option>
                                </select>
                                <input class="input-group-addon btn btn-sm btn-primary" type="submit" value="搜索">
                            </div>
                        </form>
                    </div>
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-exam-info">考场详情</button>
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-stu-grade-list">单科查看
                        </button>
                    </div>
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-admin">管理员</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-student">学生端</button>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead style="background-color: #00d0ff">
                    <tr>
                        <th>学号</th>
                        <th>姓名</th>
                        <th style="color: #AB9C08">考试编号</th>
                        <th style="color: #067D14">考试名称</th>
                        <th style="color: #00f729">考试科目编号</th>
                        <th style="color: #AB9C08">考试科目</th>
                        <th>考场地点</th>
                        <th>考场座位</th>
                        <th>考试日期</th>
                        <th>考试时间</th>
                        <th>考试成绩</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="StuExamList" th:each="stuexam:${stuExamInfoList}">
                        <th th:text="${stuexam.getSno()}"></th>
                        <th th:text="${stuexam.getSname()}"></th>
                        <th th:text="${stuexam.getExam_id()}"></th>
                        <th th:text="${stuexam.getExam_name()}"></th>
                        <th th:text="${stuexam.getExam_cid()}"></th>
                        <th th:text="${stuexam.getExam_cname()}"></th>
                        <th th:text="${stuexam.getExam_place()==null||stuexam.getExam_place()==''?'未安排':stuexam.getExam_place()}"></th>
                        <th th:text="${stuexam.getSeat_num()==null||stuexam.getSeat_num()==''?'未安排':stuexam.getSeat_num()}"></th>
                        <th th:text="${stuexam.getExam_date()==null||stuexam.getExam_date()==''?'未安排':stuexam.getExam_date()}"></th>
                        <th th:text="${stuexam.getExam_time()==null||stuexam.getExam_time()==''?'未安排':stuexam.getExam_time()}"></th>
                        <th>
                            <button class="btn btn-sm btn-outline-secondary" th:value="${stuexam.getGrade()}">上成绩
                            </button>
                        </th>
                    </tr>
                    </tbody>
                </table>
            </div>
        </main>
    </div>
</div>
<script src="../../static/js/jquery-3.6.0.min.js" th:src="@{/static/js/jquery-3.6.0.min.js}"
        type="text/javascript"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}" type="text/javascript"></script>
<script src="../../static/js/btn.js" th:src="@{/static/js/btn.js}"></script>
<script>
    let exam_id = [[${exam_id}]];
    $(function () {
        $('#btn-exam-info').click(function () {
            $(location).attr('href', '/admin/showExamList/' + exam_id + '/' + 1);
        })
        $('#btn-stu-grade-list').click(function () {
            $(location).attr('href', '/admin/getStuExamGradeList/' + exam_id + '/' + 1 + '/' + 1);
        })
        $('.StuExamList').each(function () {
            let sno = $(this).children().eq(0).text();
            let exam_id = $(this).children().eq(2).text();
            let exam_cid = $(this).children().eq(4).text();
            let grade = $(this).children().eq(10);
            let btn = $(this).children().eq(10).children();
            if (btn.val() !== null && btn.val() !== '') {
                btn.hide();
                grade.text(btn.val() + '分');
            } else if (btn.val() === null || btn.val() === '') {
                btn.show();
                //grade.text("");
            }
            btn.click(function () {
                $(location).attr('href', '/admin/toAddStuExamGrade/' + exam_id + '/' + exam_cid + '/' + sno);
            })


        })
        /*  $('#btn-arrange-exam-place').click(function (){
              let confirm1= confirm("确定自动安排考生考场位置!");
              if (confirm1===true){
                  $(location).attr('href', '/admin/arrangeStuExamPlace/' + exam_id);
              }
          })*/
    })
</script>
</body>
</html>